<template>
	<view class="bgView">
		<view class="title">迟到事由</view>
		<view class="lineH1"></view>
		<!-- 详细描述 -->
		<view class="uni-textarea">
			<textarea placeholder="详细说明"  @blur="editReason"/>
		</view>
		<button type="primary" @click="clockIn">迟到打卡</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latitude:'',
				longitude:'',
				address:'',
				reason:'',
			};
		},
		onLoad(event) {
			this.latitude = event.latitude;
			this.longitude = event.longitude;
			this.address = event.address;
		},
		methods: {
			editReason(res) {
				this.reason = res.detail.value;
			},
			clockIn(res){
				console.log(this.reason);
				if(this.reason === ''){
					uni.showToast({
						title:"请输入迟到事由"
					})
					return;
				}else{
					this.$http.post('ac/xagrid/appAttenceService/createPunch',{latitude:this.latitude,longitude:this.longitude,address:this.address,reason:this.reason}).then((res)=>{
						if(res.errcode === '0'){
							uni.showModal({
								title:'提示',
								content:'打卡成功',
								showCancel:false,
								complete() {
									uni.navigateBack({
										delta:2,
										animationType:'pop-out',
										animationDuration:200
									})
								}
							})
							
						}else{
							uni.showModal({
								title:"提示",
								content:res.errmsg,
							})
						}
					})
				}
			}
		},
	}
</script>

<style>
	.bgView {
		width: 100%;
		height: 100%;
	}
	.title{
		margin: 20upx;
	}
	.lineH1{
		
		height: 2upx;
		/* width: 100%; */
		margin-left: 10upx;
		background-color: #F7F7F7;
	}
	button {
		/* margin-top: 30upx; */
		/* margin-bottom: 30upx; */
		margin: 30upx;
	}
	.uni-textarea{
		height: 200upx;
	}
</style>
